<div class="home-index-middle">
    <div class="w1224">
        <div class="g-crumbs"></div>
        <div class="home-main">
<style>
.menu_check{
    color:#1657C2  !important
}
</style>

<div class="le-menu fl">
    <div class="menu-ul">
        <ul>
            <li class="ma"></i>个人中心</li>
            <li><a  href="/Home-User-index.html">个人信息</a></li>
            <li><a  href="/Home-User-safety_settings.html">安全设置</a></li>
        </ul>
        <ul>
            <li class="ma">我的收藏</li>
            <li><a  href="/Home-User-goods_collect.html">我的收藏</a></li>
        </ul>
        <ul>
            <li class="ma">订单中心</li>
            <li><a class ="menu_check" href="<?=base_url()?>index.php/home/userinfo/orderinfo/index">我的订单</a></li>
            <li><a  href="/Home-Order-comment.html">我的评价</a></li>
        </ul>
        <ul>
            <li class="ma"></i>商家中心</li>
            <li><a  href="/Home-Order-dispute.html">商家入驻</a></li>
            <li><a  href="/Home-Order-expose_list.html">数据发布</a></li>
        </ul>
    </div>
</div>
                    <div class="ri-menu fr">
                        <div class="menumain p" style="padding: 10px;">
                            <div class="navitems p" id="nav">
                                <ul>
                                    <?php if($type == 5):?>
                                    <li style="background-color:#104E8B;color: white">
                                        <a href="<?=base_url()?>index.php/home/userinfo/orderinfo/index" class="" style="color:white">全部订单</a>
                                    </li>
                                    <?php else:?>
                                    <li>
                                        <a href="<?=base_url()?>index.php/home/userinfo/orderinfo/index" class="">全部订单</a>
                                    </li>
                                    <?php endif;?>
                                    <?php if($type == 1):?>
                                    <li style="background-color:#104E8B;color: white">
                                        <a href="<?=base_url()?>index.php/home/userinfo/orderinfo/index?status=1" class="" style="color:white">待付款</a>
                                    </li>
                                    <?php else:?>
                                    <li>
                                        <a href="<?=base_url()?>index.php/home/userinfo/orderinfo/index?status=1" class="">待付款</a>
                                    </li>
                                    <?php endif;?>
                                    <?php if($type == 2):?>
                                    <li style="background-color:#104E8B;color: white">
                                        <a href="<?=base_url()?>index.php/home/userinfo/orderinfo/index?status=2" class="" style="color:white">已完成</a>
                                    </li>
                                    <?php else:?>
                                    <li>
                                        <a href="<?=base_url()?>index.php/home/userinfo/orderinfo/index?status=2" class="">已完成</a>
                                    </li>
                                    <?php endif;?>
                                </ul>
                                <!-- <div class="wrap-line" style="width: 82px; left: 23px;" >
                                    <span style="left:15px;"></span>
                                </div> -->
                            </div>
                            <div class="he" style="margin-top: -1px;"></div>
                            <div class="menu_search p">
                                <form id="search_order" action="javascript:0;" method="get">
                                    <input class="sea_ol fl" type="text" name="search_key" id="search_key" value=""  placeholder="搜索数据" />
                                     <button class="sea_et fl" style="cursor: pointer;" onclick="searchData()"></button>
                                    <!-- <select class="fl" name="select_year" onChange="this.form.submit();"> --> 
                                    <select class="fl" name="select_year">        
                                        <option selected value="">近三个月订单</option>
                                        <option  value="_this_year">今年内订单</option>
                                        <option  value="_2017">2017年订单</option>
                                        <option  value="_2016">2016年订单</option>
                                        <option  value="_2015">2015年订单</option>
                                    </select>
                                    <!-- <div class="vm fl" onclick="searchData()">查询</div> -->                         
                                </form>
                            </div>
                            <div class="order-alone-li">
                                <table border="0">
                                    <tr class="tr_nav">
                                        <th class="c_td1">数据名称</th>
                                        <th class="c_td2">交易状态</th>
                                        <th class="c_td3">购买时间</th>
                                        <th class="c_td4">订单价格(元)<i class="c_q">?</i><img src="/template/pc/rainbow/static/images/c_icon.png" class="c_icon"></th>
                                        <th class="c_td5">操作</th>
                                    </tr>
                                    <?php foreach($data as $item):?>
                                    <tr class="tr_body">
                                        <td><?php echo $item['order_name'] ?></td>
                                        <td style="color:red"><?php echo $item['status'] ?></td>
                                        <td><?php echo $item['buy_time'] ?></td>
                                        <td><?php echo $item['total_price'] ?></td>
                                        <td>
                                            <?php if($item['status'] == "未支付"):?>
                                            <!-- <a href="<?=base_url()?>index.php/home/gopay/detailPay?orderId=<?php echo $item['order_id']?>" class="c_change" target="_blank">付款</a> -->
                                            <a href="javascript:;" class="c_change" target="_blank" onclick="gopay(<?php echo $item['order_id']?>)">付款</a><a href="javascript:;" class="c_del" onclick="delorder(<?php echo $item['order_id']?>)">删除订单</a>
                                            <?php elseif($item['status'] == "已支付"):?>
                                            <a href="javascript:;" class="c_change">退货</a><a href="javascript:;" class="c_del">评价</a>
                                            <?php elseif($item['status'] == "已退货"):?>
                                            <a href="javascript:;" class="c_del">评价</a>
                                            <?php endif;?>
                                        </td>
                                    </tr>
                                    <?php endforeach;?>
                                </table>
                                <div class="c_info">评价后30天内可以修改评分，超过30天则不可修改。</div>
                                <span class="dl_load"></span>
                                <div class="c_post h360">
                                    <p><span class="c_title fl">请付款</span><span class="closeX fr"></span></p>
                                    <ul>
                                        <li><span>订单名称：</span><span id="o_name"></span></li>
                                        <li><span>订单价格：</span><span id="o_price" style="color:red"></span></li>
                                        <li><span>付款方式：</span></li>
                                        <input type="hidden" value="" id="hidden_orderId" />
                                        <li class="c_num">
                                            <div>
                                                <span><input type="radio" name="sc_num" checked id="sc_num1" value="alipay"><label for="sc_num1">支付宝</label></span>
                                                <span><input type="radio" name="sc_num" id="sc_num2" value="weixinpay"><label for="sc_num2">微信</label></span>
                                                <span><input type="radio" name="sc_num" id="sc_num3" value="unionpay"><label for="sc_num3">银联</label></span>
                                                <span><input type="radio" name="sc_num" id="sc_num4" value="accountpay"><label for="sc_num4">账户余额</label></span>
                                            </div>
                                        </li>
                                        <li class="zhu">
                                            注：付款后，目前不支持退货
                                        </li>
                                        <li class="c_a_btn">
                                            <a href="javascript:;" class="c_pay c_contact">确认支付</a>
                                            <a href="javascript:;" class="c_over">取消</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="page p">
                        <ul class="pagination" id="pagination1" style="float: right;margin: 0;margin-right: 20px;"></ul>
                     </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="hidden_pay"></div>
<script type="text/javascript">

    function searchData()
    {
        var content = $("#search_key").val();
        var type = "<?php echo $type;?>";
        if(content.replace(/(^s*)|(s*$)/g, "").length ==0){
            layer.alert("查询内容为空", {icon: 2, time: 10000});
            die();
        }
        window.location.href = "<?=base_url()?>index.php/home/userinfo/orderinfo/index?status="+type+"&content="+content;

    }


    $(".c_icon").hide();
    $(".c_info").hide();
    $(".c_q").mouseenter(function () {
        $(".c_icon").show();
        $(".c_info").show();
        $(".c_q").mouseleave(function () {
            $(".c_icon").hide();
            $(".c_info").hide();
        });
    });

    $(".c_pay").click(function(){
        var o_id = $("#hidden_orderId").val();
        var type = $('input:radio[name="sc_num"]:checked').val();
        $.ajax({
            type: "POST",
            url: "../../gopay/detailPay",
            dataType: "json",
            data: {orderId:o_id,type:type},
            success: function (data) {
                if(type == 'alipay'){
                    $("#hidden_pay").append(data.data);
                    $("#alipaysubmit").attr("target", "_blank");
                    document.forms['alipaysubmit'].submit();
                } else if(type == 'accountpay'){
                    if(data.code == 1){
                        alert(data.desc);
                        window.location.reload();
                    } else {
                        alert(data.desc);
                    }          
                } else if(type=="weixinpay"){
                    alert("功能开发中，请期待。。。");
                }
                /*if(data.code == 1){
                    layer.alert(data.desc, {icon: 2, time: 10000});
                    
                }*/
            }

        });
    });


    function gopay(orderId)
    {
        $.ajax({
            type: "POST",
            url: "getOrder",
            dataType: "json",
            data: {orderId:orderId},
            success: function (data) {
                $("#o_name").html(data.data.order_name);
                $("#o_price").html("￥ "+data.data.total_price);
                $("#hidden_orderId").val(data.data.order_id);
                $(".dl_load").show();
                $(".c_post").show();
            }
        });
    }


    $(".closeX").click(function() {
        $(".c_post").hide();
        $(".dl_load").hide();
    });
    $(".c_over").click(function() {
        $(".c_post").hide();
        $(".dl_load").hide();
    });

    function delorder(orderId)
    {
        $.ajax({
            type: "POST",
            url: "delOrder",
            dataType: "json",
            data: {orderId:orderId},
            success: function (data) {
                if(data.code == 2){
                    layer.alert(data.desc, {icon: 2, time: 10000});
                } else {
                    layer.alert(data.desc, {icon: 2, time: 10000});
                    //window.location.reload();
                    window.location.reload();
                }
            }
        });
    }


</script>
        <!--footer-s-->
        <!--footer-s-->